a11y: Add a simple test case for GtkButton's accessible state
authorEmmanuele Bassi <ebassi@gnome.org>
Sun, 26 Jul 2020 19:30:35 +0000 (20:30 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 26 Jul 2020 20:27:03 +0000 (21:27 +0100)
testsuite/a11y/button.c [new file with mode: 0644]
testsuite/a11y/meson.build

diff --git a/testsuite/a11y/button.c b/testsuite/a11y/button.c
new file mode 100644 (file)
index 0000000..9c5fdad
--- /dev/null
@@ -0,0 +1,37 @@
+#include <gtk/gtk.h>
+
+static void
+button_role (void)
+{
+  GtkWidget *button = gtk_button_new ();
+  g_object_ref_sink (button);
+
+  gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_BUTTON);
+
+  /* Simple command buttons have a "pressed" state set to "undefined" */
+  gtk_test_accessible_assert_state (button, GTK_ACCESSIBLE_STATE_PRESSED, GTK_ACCESSIBLE_VALUE_UNDEFINED);
+
+  g_object_unref (button);
+}
+
+static void
+button_label (void)
+{
+  GtkWidget *button = gtk_button_new_with_label ("Hello");
+  g_object_ref_sink (button);
+
+  gtk_test_accessible_assert_property (button, GTK_ACCESSIBLE_PROPERTY_LABEL, "Hello");
+
+  g_object_unref (button);
+}
+
+int
+main (int argc, char *argv[])
+{
+  gtk_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/a11y/button/role", button_role);
+  g_test_add_func ("/a11y/button/label", button_label);
+
+  return g_test_run ();
+}
index ec50ba4273275f59a84ce33fa0cd958fec2a3824..9f0f45738bfca76e60fa605354bc87f7e28adb24 100644 (file)
@@ -10,6 +10,7 @@ testdatadir = join_paths(installed_test_datadir, 'gtk')
 #  - 'link_args': (array): additional linker arguments
 #  - 'suites': (array): additional test suites
 tests = [
+  { 'name': 'button' },
 ]